Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Click the button to create a DL, DT and DD element: a description list, with terms and descriptions.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.createElement("DL"); x.setAttribute("id", "myDL"); document.body.appendChild(x); var y = document.createElement("DT"); var txt1 = document.createTextNode("Coffee"); y.appendChild(txt1); y.setAttribute("id", "myDT"); document.getElementById("myDL").appendChild(y); var z = document.createElement("DD"); var txt2 = document.createTextNode("Black hot drink"); z.appendChild(txt2); document.getElementById("myDL").appendChild(z); } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_dt_create by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:01:22 GMT --> </html>
Result:
Try it Yourself - © w3schools.com